﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQuarters.WebQuarters.Core;
using OpenQuarters.WebQuarters.Utils;

namespace OpenQuarters.WebQuarters.Core
{
    [Serializable]
    public class ItemListerConfiguration
    {
        private string method = null;

        public string Method
        {
            get { return method; }
            set { method = value; }
        }

        private List<Filter> filters = new List<Filter>();

        public List<Filter> Filters
        {
            get { return filters; }
            set { filters = value; }
        }

        private List<Ordering> ordering = new List<Ordering>();

        public List<Ordering> Ordering
        {
            get { return ordering; }
            set { ordering = value; }
        }

        private string summaryView = "";

        public string SummaryView
        {
            get { return summaryView; }
            set { summaryView = value; }
        }

        private string summaryItemView = "";

        public string SummaryItemView
        {
            get { return summaryItemView; }
            set { summaryItemView = value; }
        }

        private string mainView = "";

        public string MainView
        {
            get { return mainView; }
            set { mainView = value; }
        }

        private string paginationView = "";

        public string PaginationView
        {
            get { return paginationView; }
            set { paginationView = value; }
        }

        private string fullViewPage = "";

        public string FullViewPage
        {
            get { return fullViewPage; }
            set { fullViewPage = value; }
        }

        private bool maintainList = false;

        public bool MaintainList
        {
            get { return maintainList; }
            set { maintainList = value; }
        }

        private string itemListerId = "";

        public string ItemListerId
        {
            get { return itemListerId; }
            set { itemListerId = value; }
        }

        private PaginationMode paginationMode = PaginationMode.Number_List;

        public PaginationMode Pagination_Mode
        {
            get { return paginationMode; }
            set { paginationMode = value; }
        }

        private PaginationPosition paginationPosition = PaginationPosition.Top;

        public PaginationPosition Pagination_Position
        {
            get { return paginationPosition; }
            set { paginationPosition = value; }
        }

        private int itemsPerPage = 5;

        public int Items_Per_Page
        {
            get { return itemsPerPage; }
            set { itemsPerPage = value; }
        }

        private int currentPage = 1;

        public int Current_Page
        {
            get { return currentPage; }
            set { currentPage = value; }
        }

        public static List<ItemDefinition> GetDraftItems(string Id)
        {
            return SessionItem.GetItem<List<ItemDefinition>>("ItemLister." + Id, () => new List<ItemDefinition>());
        }

        public List<ItemDefinition> DraftItems
        {
            get { return GetDraftItems(ItemListerId); }
        }

        public ItemListerConfiguration()
        {
        }
    }
}
